package com.bf.electroplating.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.contingencyplan.ComContingencyPlanDTO;
import com.bf.electroplating.pojo.dto.contingencyplan.ComContingencyPlanQueryDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.contingencyplan.ComContingencyPlanVO;
import com.bf.electroplating.service.ComContingencyPlanService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping ( "/com-contingency-plan" )
@Tag ( name = "应急预案管理", description = "应急预案管理相关接口" )
public class ComContingencyPlanController {


	@Resource
	private ComContingencyPlanService contingencyPlanService;

	@PostMapping ( "/pageList" )
	@Operation ( summary = "分页查询应急预案列表", description = "分页查询应急预案列表" )
	public ResultVO < Page < ComContingencyPlanVO > > pageList ( @RequestBody ComContingencyPlanQueryDTO queryDTO ) {
		return contingencyPlanService.pageList ( queryDTO );
	}

	@Idempotent
	@PostMapping ( "/saveData" )
	@Operation ( summary = "新增/编辑应急预案", description = "新增/编辑应急预案" )
	public ResultVO < String > saveData ( @RequestBody @Validated ComContingencyPlanDTO dto ) {
		return contingencyPlanService.saveData ( dto );
	}

	@PostMapping ( "/delete" )
	@Operation ( summary = "删除应急预案", description = "删除应急预案" )
	public ResultVO < String > delete ( @RequestBody List < String > ids ) {
		return contingencyPlanService.delete ( ids );
	}

	@PostMapping ( "/detail" )
	@Operation ( summary = "获取应急预案详情", description = "获取应急预案详情" )
	public ResultVO < ComContingencyPlanVO > getDetail ( @RequestBody IdDTO idDTO ) {
		return contingencyPlanService.getDetail ( idDTO.getId () );
	}



}
